package com.geh.learn.guava;

import com.google.common.base.Splitter;
import com.google.common.base.Strings;

import java.util.List;

public class Spliter {

    public static void main(String[] args) {
        Splitter sp1 = Splitter.on(';').trimResults().omitEmptyStrings();
        Splitter sp2 = Splitter.on("=").trimResults().omitEmptyStrings().limit(2);

        sp1.split("a=;b=;c=12;c=13;;").forEach(str -> {
            List<String> kvList = sp2.splitToList(str);
            String key = kvList.size() > 0 ? kvList.get(0) : null;
            String value = kvList.size() > 1 ? kvList.get(1) : null;
            if (!Strings.isNullOrEmpty(key) && !Strings.isNullOrEmpty(value)) {
                System.out.println(key);
                System.out.println(value);
            }

        });

    }

}
